﻿/* 
 * TABLE: Messages 
 */

/* 
 * TABLE: Messages 
 */

CREATE TABLE Messages(
    MessageId      int              IDENTITY(1,1),
    DateOfRead     datetime         NULL,
    DateOfSend     datetime         NOT NULL,
    Message        nvarchar(max)    NOT NULL,
    RecipientId    int              NOT NULL,
    SenderId       int              NOT NULL,
    CONSTRAINT PK_Messages PRIMARY KEY NONCLUSTERED (MessageId)
)
GO
ALTER TABLE Messages ADD CONSTRAINT FKUsers_Messages 
    FOREIGN KEY (SenderId)
    REFERENCES Users(UserId)
GO
/* 
 * TABLE: Messages 
 */

/* 
 * TABLE: Messages 
 */

ALTER TABLE Messages ADD CONSTRAINT FKUsers_Messa15 
    FOREIGN KEY (RecipientId)
    REFERENCES Users(UserId)